package com.itheima.controller;

import com.itheima.domain.vo.Result;
import com.itheima.pojo.ClazzOption;
import com.itheima.pojo.JobOption;
import com.itheima.service.EmpService;
import com.itheima.service.ReportService;
import com.itheima.service.StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "统计报表", description = "统计报表相关接口")
@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private EmpService empService;
    @Autowired
    private ReportService reportService;
    @Autowired
    private StudentService studentService;

    @Operation(summary = "员工职位统计", description = "统计各职位员工人数")
    @GetMapping("/empJobData")
    public Result getEmpJobData() {
        log.info("员工职位人数统计");
        JobOption jobOption = reportService.empJobData();
        return Result.success(jobOption);

    }

    @Operation(summary = "员工性别统计", description = "统计员工性别分布")
    @GetMapping("/empGenderData")
    public Result getEmpGenderData() {
        log.info("员工性别人数统计");

        List<Map> genderList = reportService.empGenderData();

        return Result.success(genderList);
    }

    @Operation(summary = "班级人数统计", description = "统计各班级学生人数")
    @GetMapping("/studentCountData")
    public Result studentCountData() {
        log.info("班级人数统计...");
        ClazzOption clazzOption = reportService.clazzCountData();

        return Result.success(clazzOption);
    }

    @Operation(summary = "学生学历统计", description = "统计学生学历分布")
    @GetMapping("/studentDegreeData")
    public Result studentDegreeData() {
        log.info("学员学历统计...");
        List<Map> degreeList = reportService.studentDegreeData();

        return Result.success(degreeList);
    }
}
